import shutil
import os
import time 
#svn
SVNADD = 'svn add {0}'
SVNCOMMIT =  'svn commit -m "commitnewversion" --username=qiqian --password=123456'

SVNPath = '/Users/admin/client/updataSvn/res_update/H5/'
UPSERVERPath = '/Users/admin/client/ansible_workspace/'
def getSVNADDCMD(zipname):
  return SVNADD.format(zipname)

if __name__ == "__main__":
    Branchname = os.environ['CustomerBranch']
    Producttype = os.environ['Producttype']
    updataSvnDir = "./updataSvn/"
    allBranchdir  = "./H5_"+Branchname
    print("allBranchdir   copyfile  is ",allBranchdir)
    
    if os.path.exists("./build/web-mobile"):
        zipname = time.strftime("%Y%m%d%H%M%S", time.localtime())+Branchname+"_H5"+"_"+Producttype
        shutil.make_archive(SVNPath+zipname, "zip", "./build/web-mobile")
        os.chdir(SVNPath)
        svnaddcmd = getSVNADDCMD(zipname+".zip")
        print("svnaddcmd  is ",svnaddcmd)
        os.system(svnaddcmd)
        os.system(SVNCOMMIT)
    if os.path.exists(UPSERVERPath+"hotupdatah5.zip"):
        os.remove(UPSERVERPath+"hotupdatah5.zip")
    zipname = "hotupdatah5"
    shutil.make_archive(UPSERVERPath+zipname, "zip", "/Users/admin/client/build/web-mobile")
        
        



